﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using FileConvertPdfSystemBLL;
using FileConvertPdfSystemModel;

namespace FileConvertPdfSystemWeb
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void BtnRegiste_Click(object sender, EventArgs e)
        {
            FileConvertPdfSystemModel.UserInformation user = new FileConvertPdfSystemModel.UserInformation();
            //FileConvertPdfSystemModel.UserInformation usermodel = new FileConvertPdfSystemModel.UserInformation();

            FileConvertPdfSystemBLL.UserInformation1 useradd = new FileConvertPdfSystemBLL.UserInformation1();

            user = useradd.Get_SingUserInformation(TxtName.Text.ToString());
            if (user.UserNameLogin == TxtName.Text.ToString())
            {
                Response.Write("<script>alert('该用户名已经存在,请重新输入注册信息！');location.href='Register.aspx';</script>");
            }
            else
            {
                user.UserNameLogin = TxtName.Text.ToString();
                user.Sex = DpSex.Text.ToString();
                user.Password = TxtPassword.Text.ToString();
                user.TrueName = TxtTureName.Text.ToString();
                user.Questions = DpPasswordQuest.Text.ToString();
                user.Answers = TxtQuestAnsWer.Text.ToString();
                user.PostCode = TxtPostCode.Text.ToString();
                user.Emails = TxtEmail.Text.ToString();
                user.Phonecode = TxtPhone.Text.ToString();
                user.Address = TxtAddress.Text.ToString();
                user.City = TxtLiveCity.Text.ToString();
                user.Score = 1;
                user.LoadTime = Convert.ToDateTime("1987-02-20");
                user.LastLoginTime = DateTime.Now;
                useradd.Add_UserInformation(user);

                Response.Write("<script>alert('注册成功，请登录系统！');location.href='uploadFileConvertpdf.aspx';</script>");
            }
        }

        protected void BtnCheckUser_Click(object sender, EventArgs e)
        {
            FileConvertPdfSystemModel.UserInformation user = new FileConvertPdfSystemModel.UserInformation();
            FileConvertPdfSystemBLL.UserInformation1 useradd = new FileConvertPdfSystemBLL.UserInformation1();
            user = useradd.Get_SingUserInformation(TxtName.Text.ToString());
            if (user.UserNameLogin == TxtName.Text.ToString())
            {
                Response.Write("<script>alert('该用户名已经存在,请用别的用户名注册！');</script>");
                TxtName.Text = string.Empty;
                TxtName.Focus();
            }
            else
            {
                Response.Write("<script>alert('该用户名可以使用');</script>");
            }
           


        }
    }
}